def show_todos():
    print("\n待办事项列表：")
    for task_id,task in todos.items():
        print(f"{task_id}.{task.get('name')} - {task.get('status')}")

todos = {}
current_id = 1

while True:
    show_todos()
    action = input("请选择操作（add/update/delete/complete/quit）：").strip().lower()

    if action == "add":
        task_name = input("请输入代表事项：")
        task = {"name":task_name, "status":"未完成"}
        todos[current_id] = task
        current_id += 1
        print("事项已添加成功")
    elif action == "update":
        task_id = input("请输入待办编号：")
        if task_id.isdigit() and int(task_id) in todos:
            task = input("请输入更新事项：")
            todos[int(task_id)].update({"name":task});
            print("事项已更新")
        else:
            print("无效的编号")
    elif action == "delete":
        task_id = input("请输入待办编号：")
        if task_id.isdigit() and int(task_id) in todos:
            del todos[int(task_id)]
            print("事项已删除")
        else:
            print("无效的编号")
    elif action == "complete":
        task_id = input("请输入待办编号：")
        if task_id.isdigit() and int(task_id) in todos:
            todos[int(task_id)]["status"] = "已完成"
            print("事项已完成")
        else:
            print("无效的编号")
    elif action == "quit":
        print("退出程序")
        break
    else:
        print("无效的操作")

